package team.dmh.wx.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import team.dmh.wx.entity.ChatMsg;
import team.dmh.wx.enums.ChatMsgFlagEnum;
import team.dmh.wx.service.IChatMsgService;
import team.dmh.wx.util.Result;
import team.dmh.wx.util.ResultUtils;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzk
 * @since 2018-10-15
 */
@RestController
@RequestMapping("/chat")
@Api(tags = "聊天接口")
public class ChatMsgController {

    @Autowired
    private IChatMsgService chatMsgService;

    @ApiOperation(value = "获取未接受消息列表")
    @GetMapping("/getUnReadMsgList")
    public Result getUnReadMsgList(String acceptUserId){
        List<ChatMsg> chatMsgList=chatMsgService.list(new LambdaQueryWrapper<ChatMsg>()
                .eq(ChatMsg::getAcceptUserId,acceptUserId)
                .eq(ChatMsg::getFlag,ChatMsgFlagEnum.UN_SIGN.type));
        return ResultUtils.success(chatMsgList);
    }
}
